package cn.ffcs.uec.outStaffAdjustPostApply.component;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zul.Bandbox;

import cn.ffcs.uec.outStaffAdjustPostApply.component.bean.UecWaCrtBandboxExtBean;
import cn.ffcs.uec.salary.model.UecWaCrt;

@Controller
@Scope("prototype")
public class UecWaCrtBandboxExt extends Bandbox implements IdSpace {

	private static final long serialVersionUID = -5155333560914909539L;
	/**
	 * 页面对应的bean
	 */
	private UecWaCrtBandboxExtBean bean = new UecWaCrtBandboxExtBean();
	/**
	 * 页面zul
	 */
	public static final String ZUL = "/pages_nmg/uec_salary/comp/uecWaCrtBandbox/uecWaCrt_bandbox_ext.zul";
	
	private UecWaCrt uecWaCrt;
	
	private UecWaCrtListboxExt uecWaCrtListboxExt;
	
	public UecWaCrtBandboxExt() {
		Executions.createComponents(ZUL, this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');
		
		uecWaCrtListboxExt = (UecWaCrtListboxExt)this.getFellow("uecWaCrtListboxExt");
		uecWaCrtListboxExt.addForward("onSelectUecWaCrt", this, "onSelectUecWaCrtResponse");
	}
	
	/**
	 * 事件监听
	 * @param event
	 */
	public void onSelectUecWaCrtResponse(final ForwardEvent event) {
		uecWaCrt = (UecWaCrt) event.getOrigin().getData();
		if (null != uecWaCrt) {
			setValue(uecWaCrt.getWaCrtName());
			this.close();
		}
		Events.postEvent("onUecWaCrtEditSelected",this, uecWaCrt);
	}
	
	/**
	 * 点击”确认“按钮事件
	 */
	public void onClick$okButton() {
		this.close();
	}

	/**
	 * 点击“取消”按钮事件
	 */
	public void onClick$cancelButton() {
		this.close();
	}
	
}
